﻿/******************************************************    
文件名:GetQuestion.cs
版权  (c)  2010-11-23 淘渺圈圈工作室
作者:黄媛媛
创建日期:2010-12-07
维护人员:黄媛媛
维护日期:2010-12-07
文件功能描述:金属材料热处理网络学习平台_随机生成试题
******************************************************/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Web;
using Mmht.DB;
using System.Configuration;
using System.Collections;

namespace Mmht.BT
{
    public class GetQuestion
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="max">随机数最大上限</param>
        /// <param name="total">产生随机数个数</param>
        /// <returns></returns>
        public List<int> getQuestionID(int max, int total)
        {
            List<int> list = new List<int>();
            Random random = new Random();
            int number = random.Next(max);
            list.Clear();
            if (max < total)
            {
                for (int i = 0; i < max; i++)
                {
                    list.Add(i);
                }
            }
            else
            {
                for (int i = 0; i < total; i++)
                {
                    while (list.Contains(number))
                    {
                        number = random.Next(max);
                    }
                    list.Add(number);
                }
            }
            //list.Sort();
            return list;
        }

        
    }
}
